package com.dz.server.controller;

import com.dz.server.pojo.Product;
import com.dz.server.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class IndexController {
    @Autowired
    private ProductService productService;
    //跳转到首页
    @RequestMapping("/toIndex")
    public String toIndex(Model model){
        List<Product> products = productService.list();
        model.addAttribute("products",products);
        return "index";
    }
}
